﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Criterion;
using ZDSoft.UPMS.Model;
using System.Data.SqlClient;

namespace ZDSoft.UPMS.Service
{
    public interface IServiceBase<T>
    {
        /// <summary>
        /// 创建一个实体
        /// </summary>
        /// <param name="t">实体</param>
        void Create(T t);

        /// <summary>
        /// 修改一个实体
        /// </summary>
        /// <param name="t">实体</param>
        void Update(T t);

        /// <summary>
        /// 删除一个实体
        /// </summary>
        /// <param name="id">实体ID</param>
        void Delete(int id);

        /// <summary>
        /// 查找一个实体
        /// </summary>
        /// <param name="id">实体ID</param>
        /// <returns>实体</returns>
        T FindByID(int id);

        /// <summary>
        /// 查找所有实体
        /// </summary>
        /// <returns>实体集合</returns>
        IList<T> FindAll();

        /// <summary>
        /// 根据查询条件获取所有满足条件的实体
        /// </summary>
        /// <param name="queryConditions">查询条件，可以是多个,形式如："UserName"="Lion"</param>
        /// <returns>满足条件的实体集合</returns>
        IList<T> Find(IList<ICriterion> queryConditions);

        /// <summary>
        /// 分页获取对象集合
        /// </summary>
        /// <param name="queryConditions">查询条件，可以是多个,形式如："UserName"="Michael"</param>
        /// <param name="orderList">排序方式，根据字段排序，形式如："UserName","DESC"</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">页面大小</param>
        /// <param name="count">满足条件的记录总数</param>
        /// <returns>返回满足条件的实体集合</returns>
        IList<T> GetPaged(IList<ICriterion> queryConditions, IList<Order> orderList, int pageIndex,
           int pageSize, out int count);


        /// <summary>
        /// 根据查询条件分页获取实体
        /// </summary>
        /// <param name="queryConditions">查询条件集合</param>
        /// <returns>返回满足查询条件的实体</returns>
        IList<T> Find(IList<QueryConditions> queryConditions);

        void Exec(string str);

       bool IsHaveFunction(string Name);


      void ExeNonQuery(string procedure, SqlParameter[] parameter);

      SqlParameter[] CreateSqlParameter(List<string> SqlParameterNames, List<Object> SqlValues);


    }
}
